package br.com.tcc.systemdx.domain;

import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

@MappedSuperclass
public abstract class BaseEntityAssociated<T extends BaseEntity> extends
		BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 518446792963331185L;
	
	@ManyToOne
	@JoinColumn(name="parentId", insertable=true, updatable=false, nullable=true, referencedColumnName="id")
	private T parent;
	
	public T getParent() {
		return parent;
	}
	
	public void setParent(T parent) {
		if (parent != null) {
			this.parent = parent;
		} else {
			this.parent = null;
		}
	}

}
